const useConfigurationStore = defineStore(
  'configuration',
  {
    state: () => ({
      configuration: new Array()
    }),
    actions: {
      // 获取菜单
      getConfiguration(_key) {
        if (_key == null && _key == "") {
          return null;
        }
        try {
          for (let i = 0; i < this.configuration.length; i++) {
            if (this.configuration[i].key == _key) {
              return this.configuration[i].value;
            }
          }
        } catch (e) {
          return null;
        }
      },
      // 设置菜单
      setConfiguration(_key, value) {
        if (_key !== null && _key !== "") {
          this.configuration.push({
            key: _key,
            value: value
          });
        }
      },
      // 删除菜单
      removeConfiguration(_key) {
        let bln = false;
        try {
          for (let i = 0; i < this.configuration.length; i++) {
            if (this.configuration[i].key == _key) {
              this.configuration.splice(i, 1);
              return true;
            }
          }
        } catch (e) {
          bln = false;
        }
        return bln;
      },
      // 清空菜单
      cleanConfiguration() {
        this.configuration = new Array();
      },
      // 初始菜单
      initConfiguration() {
      }
    }
  })

export default useConfigurationStore
